package arithmetic.toutiao;

import java.util.Queue;

/**
 * 头条算 瓶子
 * 两块一瓶,  两个空瓶换一瓶, 四个盖子换一瓶.
 *
 * 规律 钱数(偶数) *2 - 5.
 *
 * 扩展如果可以佘呢?
 *
 *
 * @author jiangfeng on 2022/6/16
 */
public class Test {
    public static void main(String[] args) {
        //Queue queue = new Queue();
        // Scanner input=new Scanner(System.in);
        // String str=input.next();
        //System.out.println(cacl(2)); // 1

        //System.out.println(cacl(3)); // 1
//        System.out.println(cacl(30)); //55
//        System.out.println(cacl(4)); // 1  ;  2 ping 2 gai , 1
//        System.out.println(cacl(5));
//        System.out.println(cacl(6)); //7
        // 2
        // 2 2
        // 3  1 3
        // System.out.println(cacl(5));//
        //  System.out.println(cacl(30));
        for (int i = 1; i <= 50; i++) {
            cacl(i);
        }



    }

    public static int cacl(int money) {
        int size = money / 2;  // 2

        int gai = 0; //2
        int ping = 0; // 2
        int res = 0; //2
        while (gai >= 4 || ping >= 2 || size >= 1) {
            if (size < 1 && gai < 4 && ping < 2) {
                return res;
            }
            int temp = 0;
            while (size > 0) {
                size--;
                temp++;
            }
            while (gai >= 4) {
                gai -= 4;
                temp++;
            }
            while (ping >= 2) {
                ping -= 2;
                temp++;
            }
            res += temp;
            gai += temp;
            ping += temp;

        }
        System.out.println("money:"+money+" res:"+res+" gai:"+gai+" ping:"+ping);
        return res;
    }


}
